#ifndef ABSTRACTLISTMODEL_H
#define ABSTRACTLISTMODEL_H
#include <QAbstractListModel>
#include<QStringList>
class  AbstractList   //抽象数据列表类
{
   public:
    AbstractList(const QString &name,const QString &color,const QString &number);
    QString name() const;
    QString color() const;
    QString number() const;
private:
    QString m_name;
    QString m_color;
    QString m_number;

};
class AbstractListModel : public  QAbstractListModel
{
    Q_OBJECT
public:
    enum AbstractListRoles{
         NameRole=Qt::UserRole+1,
        ColorRole,
        NumberRole
    };                               //定义抽象类成员角色
    AbstractListModel(QObject *parent=nullptr);
    void addList(const AbstractList &list);
    int rowCount(const QModelIndex &parent=QModelIndex()) const;  //返回给定父项行数
    QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const;//返回索引所在项给定角色的存储数据
protected:
    QHash<int,QByteArray> roleNames() const;  //返回模型的角色名
private:
    QList<AbstractList> m_abstractList;     //抽象列表类容器
};

#endif // ABSTRACTLISTMODEL_H
